{% extends "nmapreport/main.html" %}

{% block content %}
	<div class="container" style="margin-top:100px;">
		<div class="row">
			<div class="col s12 m4 offset-m4">
				<div class="card wmcard">
					<div class="card-content">
						<button class="btn blue" onclick="javascript:checkToken();">进入系统</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	{% if out %}
		{{ out|safe }}
	{% endif %}

	<script>
		function checkToken() {
			var token = $('#token').val();
			csrftoken = $('input[name="csrfmiddlewaretoken"]').val();
			$.post('/view/login/', {
				'csrfmiddlewaretoken': csrftoken,
				'token': '123456',
			}).done(function(d) {
				if(d['auth'] == 'ok') {
					location.href='/';
				} else {
					swal("Error", "Invalid token", "error")
				}
			});
		}
	</script>
{% endblock %}
